% GAUTIER LE BIHAN - 2020
% Replication files for “Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector Menu-Cost Model�? –Review of Economics and Statistics
%
% This code produces   Appendix figure F (identu_MCKR.pdf) from simulated moments 

clear all
close all
clear matrix
clc

cd ..\..\Simu_identification\simu_univ_MC_KR
load stat_outsample_testh.mat 

stat_outsampleb=stat_outsample_testh(:,1:end)
%% The first 4 columns are the parameters
params_vec=stat_outsampleb(:, 3:5)   ;
%% The first folllowing columns are the moments
moments_vec=stat_outsampleb(:, 6:end)  ;

disp( '%%%%%%%%%%%%%%%%    Parameters value for the baseline case   %%%%%%%%%%%%%%%%%%%%%%%%%%');
param0=[0; 0.004; 0.0673; 0.0710];

rho_base =0.694600000000000
mu_c_base =0.004
sig_eps_a_base =0.0673
pz_base = .0710

%% Note when  sig_eps_a ==0 , then the relation between moments and mu_c is well behaved (average_dp increasing function of mu_c
%%% Interpretation : when mu_c is large price changes are mainly trigerred by the inflation trend
param_plot = 1;
figure(1);
aa = abs(params_vec(:,2)-sig_eps_a_base );
aa_min = min(aa);
cc = abs(params_vec(:,3)-pz_base );
cc_min = min(cc);
dd = abs(params_vec(:,1)-mu_c_base );
dd_min = min(dd);
plot_vec = (aa==aa_min)&(cc==cc_min)&(dd~=dd_min);

subplot(3,5,1)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-b')
plot([mu_c_base mu_c_base],[0 0.2], '--r');
axis([0.0001 max(params_vec(:,1)) 0 0.2])
xlabel('\mu') % x-axis label
ylabel('Freq. Changes') % y-axis label
hold off;

subplot(3,5,2)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-b')
plot([mu_c_base mu_c_base],[0.5 0.95], '--r');
axis([0.0001 max(params_vec(:,1)) 0.5 0.95])
xlabel('\mu') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(3,5,3)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-b')
plot([mu_c_base mu_c_base],[0 0.08], '--r');
axis([0.0001 max(params_vec(:,1)) 0.0 0.08])
xlabel('\mu') % x-axis label
ylabel('Median') % y-axis label
hold off;

subplot(3,5,4)
hold on;plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-b')
plot([mu_c_base mu_c_base],[0 0.15], '--r');
axis([0.0001 max(params_vec(:,1)) 0.0 0.15])
xlabel('\mu') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(3,5,5)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-b')
plot([mu_c_base mu_c_base],[0 5], '--r');
axis([0.001 max(params_vec(:,1))  0 5])
xlabel('\mu') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;


param_plot = 2;
aa = abs(params_vec(:,1)- mu_c_base);
aa_min = min(aa);
cc = abs(params_vec(:,3)-pz_base );
cc_min = min(cc);
dd = abs(params_vec(:,2)-sig_eps_a_base );
dd_min = min(dd);
plot_vec = (aa==aa_min)&(cc==cc_min)&(dd~=dd_min);

subplot(3,5,6)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0 0.2], '--r');
axis([min(params_vec(:,2)) max(params_vec(:,2)) 0 0.2])
xlabel('\sigma') % x-axis label
ylabel('Freq. Changes') % y-axis label
hold off;

subplot(3,5,7)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0.5 0.95], '--r');
axis([min(params_vec(:,2)) max(params_vec(:,2)) 0.5 0.95])
xlabel('\sigma') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(3,5,8)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0 0.08], '--r');
axis([min(params_vec(:,2)) max(params_vec(:,2))  0.0 0.08])
xlabel('\sigma') % x-axis label
ylabel('Median') % y-axis label
hold off;

subplot(3,5,9)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0 0.15], '--r');
axis([min(params_vec(:,2)) max(params_vec(:,2)) 0.0 0.15])
xlabel('\sigma') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(3,5,10)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-b');
plot([sig_eps_a_base sig_eps_a_base],[0 5], '--r');
axis([min(params_vec(:,2)) max(params_vec(:,2))  0 5])
xlabel('\sigma') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;

param_plot = 3;
aa = abs(params_vec(:,1)- mu_c_base);
aa_min = min(aa);
cc = abs(params_vec(:,2)-sig_eps_a_base );
cc_min = min(cc);
dd = abs(params_vec(:,3)-pz_base );
dd_min = min(dd);
plot_vec = (aa==aa_min)&(cc==cc_min)&(dd~=dd_min);


subplot(3,5,11)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-b');
plot([pz_base pz_base],[0 0.2], '--r');
axis([0.05 max(params_vec(:,3)) 0. 0.2])
xlabel('p_a') % x-axis label
ylabel('Freq. changes') % y-axis label
hold off;

subplot(3,5,12)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-b');
plot([pz_base pz_base],[0.5 0.95], '--r');
axis([0.05 max(params_vec(:,3))  0.5 0.95])
xlabel('p_a') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(3,5,13)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-b');
plot([pz_base pz_base],[0 0.08], '--r');
axis([0.05 max(params_vec(:,3))  0 0.08])
xlabel('p_a') % x-axis label
ylabel('Median') % y-axis label
hold off

subplot(3,5,14)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-b');
plot([pz_base pz_base],[0.0 0.15], '--r');
axis([0.05 max(params_vec(:,3)) 0.0 0.15])
xlabel('p_a') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(3,5,15)
hold on;
size(params_vec(plot_vec~=0,param_plot))
size(moments_vec(plot_vec~=0,5))

plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-b');
plot([pz_base pz_base],[0 5], '--r');
axis([0.05 max(params_vec(:,3)) 0 5])
xlabel('p_a') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;
print('..\..\..\figures\identu_MCKR.pdf','-dpdf', '-fillpage')



